package cn.lcsjsxy.yxz.day.Thread;

//运行
public class Run {
    public static void main(String[] args) {

        //
//        MyThread4 t3 = new MyThread4();
//        t3.start();
//        MyThread5 t4 = new MyThread5();
//        t4.start();

//        MyThread6 t5 = new MyThread6("t5");
//        MyThread6 t55 = new MyThread6("t55");
//
//        t5.start();
//        t55.start();

        //构建线程对象时，可以只把逻辑传递给这个对象  规则:() -> {逻辑}
//        Thread t6 = new Thread(() -> {
//            System.out.println("线程执行");
//        });
//
//        t6.start();

        //构建线型对象时，可以传递实现了Runnable接口得类的对象,一般使用匿名类
        Thread t7 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("线程执行");
            }
        });

        t7.start();

        System.out.println("main线程程序执行完毕!!!");

    }

}

//自定义线程
//重写运行的方法
class MyThread4 extends Thread{
    @Override
    public void run() {
        System.out.println("t3 线程执行");
    }
}
class MyThread5 extends Thread{
    @Override
    public void run() {
        System.out.println("t4 线程执行");
    }
}
class MyThread6 extends Thread{
    private String threadName;
    public MyThread6( String name){
        threadName = name;
    }
    @Override
    public void run() {
        System.out.println(threadName + "线程执行");
    }
}